/**
 * 
 */
package wsdl.service;

import java.util.HashMap;

/**
 * @author Maurice & Topia
 *
 */
public class WSDLPortType {
	private String name;
	private HashMap<String, WSDLOperation> operations;
	
	public WSDLPortType(String name) {
		this.name = name;
		operations = new HashMap<String, WSDLOperation>();
	}
	
	public void addOperation(String name, WSDLOperation operation){
		operations.put(name, operation);
	}
	
	public String getName() {
		return name;
	}
	
	public WSDLOperation getOperation(String name){
		WSDLOperation operation = operations.get(name);
		
		if(operation == null){
			System.err.println("(WSDLPortType) Unknown operation " + name);
		}
		
		return operation;
	}
	
	@Override
	public String toString() {
		String portTypeStr = "portType " + name + " {\n";
		
		for(String operation : operations.keySet()){
			portTypeStr += operations.get(operation).toString() + "\n";
		}
		
		portTypeStr += "};";
		
		return portTypeStr;
	}
}
